package cn.bj.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.bj.beans.Yxhz;
import cn.bj.beans.YxhzExample;
import cn.bj.dao.YxhzMapper;

@Service
public class YxhzService {

	@Autowired
	YxhzMapper yxhzMapper;

	// 插入
	public int insrtYxhz(Yxhz yxhz) {
		return yxhzMapper.insert(yxhz);
	}

	// 查询所有
	public List<Yxhz> getAllYxhz() {
		YxhzExample yxhzExample = new YxhzExample();
		yxhzExample.setOrderByClause("`sort` DESC,id ASC");
		return yxhzMapper.selectByExample(yxhzExample);
	}

	// 删除
	public int deleteYxhz(Integer id) {
		return yxhzMapper.deleteByPrimaryKey(id);
	}

	// 查询单个
	public Yxhz selectById(Integer id) {
		return yxhzMapper.selectByPrimaryKey(id);
	}

	// 修改
	public int updateYxhz(Yxhz yxhz) {
		return yxhzMapper.updateByPrimaryKey(yxhz);
	}
}
